package com.woniuxy.controller;

import com.woniuxy.pojo.User;
import com.woniuxy.service.UserService;
import com.woniuxy.util.ResultDto;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {
    @Autowired
    private UserService userService;
    @ApiOperation(value = "查询所有用户信息",httpMethod = "GET",
            protocols = "HTTP",produces = "application/json",
            response = ResultDto.class,notes = "查询所有用户信息")
    @GetMapping(value = "/user")
    public ResultDto selectAllUsers(){
        ResultDto dto=new ResultDto();
        List<User> all=userService.findAllUsers();
        if(all!=null&&all.size()>0){
            dto.setCode(200);
            dto.setMsg("success");
            dto.setData(all);
        }else{
            dto.setCode(1001);
            dto.setMsg("failure");
        }
        return dto;
    }
}
